﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using DG.Tweening;

namespace Battle
{
    public class Bullet_Aoe : BulletBase
    {
        //记录击中目标时间，避免反复触发
        protected List<ICanHitObj> listHitObj=new List<ICanHitObj>();

        private void Awake()
        {
            transform.localScale = Vector3.zero;
        }

        public void SetAoeSize(Vector2 size)
        {
            if (gameObject.activeInHierarchy)
            {
                transform.DOKill();
                transform.DOScale(new Vector3(size.x, size.y, 1), 0.1f);
            }
            else
            {
                transform.localScale = new Vector3(size.x, size.y, 1);
            }
        }

        public override void InitBulletData(ST_BulletData bulletData, IBulletHitHandler hitHandler, IEnemyTargetGetter targetGetter)
        {
            base.InitBulletData(bulletData, hitHandler, targetGetter);

            eM_BulletType = EM_BulletType.AOE;
        }

        protected override void OnHitObj(ICanHitObj target)
        {
            if (target != null && listHitObj.Contains(target)) return;

            base.OnHitObj(target);
        }
        protected override void AfterHitObj(ICanHitObj target)
        {
            //TODO 如果不能重复命中目标，就在这里存记录
            if (!listHitObj.Contains(target))
                listHitObj.Add(target);
        }

        public override bool CheckNeedDestory()
        {
            return false;
        }
    }
}
